#pragma once

#include <string>
#include <memory>
#include <vector>
#include <unordered_map>

class Component
{
public:
    Component(std::string name);

public:
    auto connectWith(std::shared_ptr<Component> component) -> void;
    auto toString() -> std::string;

    auto name() const -> const std::string&
    { return this->_name; }

private:
    std::string _name;
    std::vector<std::shared_ptr<Component>> _connects; 
};

using RCComponent = std::shared_ptr<Component>;
using ComponentDict = std::unordered_map<std::string, RCComponent>;

class Apparatus
{
public:
    Apparatus(const std::string& filepath);

public:
    auto showComponents() -> void;

private:
    auto splitName(const std::string& line) -> std::vector<std::string>;
    auto create(std::string name) -> RCComponent;

private:
    ComponentDict _components;
};